﻿Ext.define('HIT.view.SetRuleSelectPanel', {
    extend: 'Ext.form.Panel',
    alias:'widget.setregulars',

	cls : 'custom-grid',
    height: 380,
    width: 510,
    layout: {
        type: 'absolute'
    },
    bodyPadding: 10,

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                       {
		                 xtype: 'fieldset',
		                 x: 40,
		                 y: 10,
		                 title : Share.T('规则选择'),		      
		                 height: 270,
		                 id: 'set-regulars-fieldset',
		                 width: 480,
		                 layout: {
		                    type: 'absolute'
		                 },
		             items:[
		                    {
		          	         xtype:'label',
		          	         x:40,
		                     y: 10,
		                     text:Share.T('特殊规则')
		                    },
							{	 xtype   : 'checkboxgroup',
		                         margin: '20 20',
		                         columns : 3,
			                      x: 40,
			                      y: 10,
		                         items   : [{
		                        	         boxLabel  : Share.T('退货'),
		                                     id: 'set-regulars-check-1'  
		                                     
		                                 },{
		                                	 boxLabel  : Share.T('折扣'),
		                                     id: 'set-regulars-check-2'       
		                                 },{
		                                	 boxLabel  : Share.T('返利'),
		                                     id: 'set-regulars-check-3' 
		                                 }
		                                 , {
		                                     boxLabel  : Share.T('拆分'),
		                                     id: 'set-regulars-check-4' 
		                                 }
		                                 , {
		                                     boxLabel  : Share.T('发票分组'),
		                                     id: 'set-regulars-check-5' 
		                                 }
		                                 , {
		                                     boxLabel  : Share.T('合并明细'),
		                                     id: 'set-regulars-check-14' 
		                                 }
		                                 ],                   listeners: {
		                                     afterlayout: {
		                                         fn: me.LoadRegularsData,
		                                         scope: me
		                                     }
		                                 }
						},
						{	 xtype   : 'checkboxgroup',
	                         margin: '20 20',
	                         columns : 3,
		                      x: 40,
		                      y: 80,
	                         items   : [{
	                        	         boxLabel  : Share.T('商品名'),
	                                     id: 'set-regulars-check-6'  
	                                     
	                                 },{
	                                	 boxLabel  : Share.T('客户'),
	                                     id: 'set-regulars-check-7'       
	                                 },{
	                                	 boxLabel  : Share.T('单位'),
	                                     id: 'set-regulars-check-8' 
	                                 }
	                                 , {
	                                     boxLabel  : Share.T('规格'),
	                                     id: 'set-regulars-check-9' 
	                                 }
	                                 ]
					},
					{
		       	               xtype:'label',
		       	               x: 40,
		                       y: 80,
		                       text:Share.T('替换')
		                      },
								{	 xtype   : 'checkboxgroup',
			                         margin: '20 20',
			                         columns : 3,
				                      x: 40,
				                      y: 150,
			                         items   : [{
			                        	         boxLabel  : Share.T('摘要'),
			                                     id: 'set-regulars-check-10'  
			                                     
			                                 },{
			                                	 boxLabel  : Share.T('备注'),
			                                     id: 'set-regulars-check-11'       
			                                 },{
			                                	 boxLabel  : Share.T('单据状态'),
			                                     id: 'set-regulars-check-12' 
			                                 }			                                
			                                 ]
							}, {   
		                       xtype:'label',
			                   x: 40,
		                       y: 150,
		                       text:Share.T('自定义')
		                      }
		                     ]   
		                 }        
                   ],
                   listeners: {
                       afterlayout: {
                           fn: me.LoadRegularsData,
                           scope: me
                       }
                   }
                   });
      me.callParent(arguments);
    },
    LoadRegularsData: function(abstractcontainer, layout, options) {

    	Share.AjaxRequest({
            url      : ctx + '/getCheckedRule',
            showMsg: false,
            params   : {
            },
            callback : function(json) {
            	for(var i=0; i<json.length; i++)
            	{
              	  if(json[i].value==11){
             			Ext.getCmp('set-regulars-check-1').setValue(true);
              	  }
              	  if(json[i].value==12){
             			Ext.getCmp('set-regulars-check-2').setValue(true);
              	  }
              	  if(json[i].value==13){
             			Ext.getCmp('set-regulars-check-3').setValue(true);
              	  }
              	  if(json[i].value==14){
             			Ext.getCmp('set-regulars-check-4').setValue(true);
              	  }
              	  if(json[i].value==15){
             			Ext.getCmp('set-regulars-check-5').setValue(true);
              	  }
              	  if(json[i].value==16){
           			Ext.getCmp('set-regulars-check-14').setValue(true);
            	  }
              	  if(json[i].value==21){
             			Ext.getCmp('set-regulars-check-6').setValue(true);
              	  }
              	  if(json[i].value==22){
             			Ext.getCmp('set-regulars-check-7').setValue(true);
              	  }
              	  if(json[i].value==23){
             			Ext.getCmp('set-regulars-check-8').setValue(true);
              	  }
              	  if(json[i].value==24){
             			Ext.getCmp('set-regulars-check-9').setValue(true);
              	  }
              	  if(json[i].value==31){
             			Ext.getCmp('set-regulars-check-10').setValue(true);
              	  }
              	  if(json[i].value==32){
             			Ext.getCmp('set-regulars-check-11').setValue(true);
              	  }
              	  if(json[i].value==33){
             			Ext.getCmp('set-regulars-check-12').setValue(true);
              	  }
            	}            	
            }
    	});
    }
});